<%@ page import="java.net.URLEncoder" %><%--
  Created by IntelliJ IDEA.
  User: Jovi
  Date: 2018/3/19
  Time: 下午5:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%
    request.setCharacterEncoding("UTF-8");

    String username = request.getParameter("username");

    if (username.equalsIgnoreCase("admin")) {
        request.setAttribute("msg", "注册失败");
        request.getRequestDispatcher("userCreate.jsp").forward(request,response);
    } else {

        session.setAttribute("username",username);
        username = URLEncoder.encode(username, "utf-8");
        Cookie cookie = new Cookie("user", username);
        cookie.setMaxAge(60);
        response.addCookie(cookie);
        //session.setMaxInactiveInterval(10);//session会话失效时间，单位秒
        response.sendRedirect("newsDetail.jsp");
    }

    out.println(username);
    out.println(request.getParameter("password"));
    String con_password = request.getParameter("con_password");
    String email = request.getParameter("email");
%>
<%=con_password%><br>
<%=email%>

</body>
</html>
